﻿using System;
using System.Web.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class HostingEnvironmentSectionManager : ConfigurationManagerBase
	{
		private HostingEnvironmentSection section;

		public HostingEnvironmentSectionManager()
		{
			this.section = (HostingEnvironmentSection)base.GetConfigurationSection("system.web/hostingEnvironment");
		}

		public void Modify(TimeSpan idleTimeout, bool shadowCopyBinAssemblies, TimeSpan shutdownTimeout)
		{
			if (idleTimeout.Ticks < 1)
			{
				idleTimeout = TimeSpan.MaxValue;
			}
			this.section.IdleTimeout = idleTimeout;
			this.section.ShadowCopyBinAssemblies = shadowCopyBinAssemblies;
			this.section.ShutdownTimeout = shutdownTimeout;
			this.Save();
		}
		public HostingEnvironmentSection GetHostingEnvironmentSection()
		{
			return this.section;
		}
	}
}
